﻿using Halcon二次开发.View.Socket通信;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Halcon二次开发.Data.SocketChild数据
{
    [Serializable]
    public class SocketDome
    {
        [NonSerialized]
        public Action<SocketDome> nameChanged;
        private string name;

        /// <summary>
        /// 名称
        /// </summary>
        public string Name
        {
            get { return name; }
            set {
                name = value;
                nameChanged?.Invoke(this);
            }
        }

        private string startStr;
        /// <summary>
        /// 开始文本
        /// </summary>
        public string StartStr
        {
            get { return startStr; }
            set { startStr = value; }
        }

        private object result;
        /// <summary>
        /// 值
        /// </summary>
        public object Result
        {
            get { return result; }
            set { result = value; }
        }
        /// <summary>
        /// 结束文本
        /// </summary>
        private string endStr;

       

        public string EndStr
        {
            get { return endStr; }
            set { endStr = value; }
        }
        private string splitStr;

        public string SplitStr
        {
            get { return splitStr; }
            set { splitStr = value; }
        }

        public SocketDome(int name, Action<SocketDome> nameChanged)
        {
            Name = "Input" + name.ToString();
            this.nameChanged = nameChanged;
            this.Result = "null";
        }
        public override string ToString()
        {
            if (result is string)
            {
                return this.startStr + (string)this.result+ this.endStr;
            }else  if (this.result.ToString()== "System.Double[]")
            {
                double[] d= (this.result as double[]);
                List<double> list= d.ToList<double>();
                string result = String.Join(SplitStr, list);
                return this.startStr + result + this.endStr;
            }else
            {

                return this.startStr + this.result.ToString() + this.endStr;
            }
        }
    }
}
